<template>
	<view class="index-main">
		<swiper-tab-head :tabBars="tabBars" :tabIndex="tabIndex" @tabtap="tabtap"></swiper-tab-head>
		<view class="uni-tab-bar">
			<view class="search-con">
				<view class="search-list">
					<block v-for="(value,key) in listData" :key="key">
					<view class="search-nr" @tap="ondoctTap(value.order_id)">
						<view class="avatarbox">
							<image :src="value.good.original_img" mode="aspectFill"></image>
						</view>
						<view class="search-nrxx">
							<view class="u-f u-f-jsb">
								<view class="xmtitle">
									<text class="telis">{{value.good.goods_name}}</text>
								</view>
								<view class="zxbtn">+{{value.good.shop_price}}</view>
							</view>
							<view class="">
								<view class="yytp u-f u-f u-f-jsb">
									<text style="font-size: 12px;line-height: 50upx;">OID:{{value.good.goods_id}}</text>
									<text style="font-size: 12px;line-height: 50upx;">{{value.add_time}}</text>
								</view>
								<view v-if="value.order_status==0" class="yybox u-f u-f-jsb">
									<text v-if="value.subtime<=0">已超过提交时间</text>
									<text v-if="value.subtime>0">{{djs(value.subtime)}}过期</text>
									<text class="simtp">进行中</text>
								</view>
								<view v-if="value.stype==2" class="yybox u-f u-f-jsb">
									<text v-if="value.subtime<=0">过期审核</text>
									<text v-if="value.subtime>0">{{djs(value.subtime)}}过期</text>
									<text class="simtp"></text>
								</view>
								<view v-if="value.stype>2" class="yybox u-f u-f-jsb">
									<text></text>
									<text class="simtp">{{tabBars[value.stype].name}}</text>
								</view>
							</view>
						</view>
					</view>
					</block>
				</view>
			</view>
			<uni-load-more :status="status" :content-text="contentText" />
		</view>
	</view>
</template>

<script>
	import uniCountdown from "@/components/uni-countdown/uni-countdown.vue"
	import swiperTabHead from "components/user/swiper-tab-head.vue";
	import loadMmore from "components/common/load-more.vue";
	import noThing from "components/common/no-thing.vue"
	export default {
		components: {
			swiperTabHead,
			loadMmore,
			noThing,
			uniCountdown
		},
		data() {
			return {
				//倒计时
				testHour: 0,
				testMinute: 0,
				testSecond: 0,
				
				swiperheight: 500,
				tabIndex: 0,
				listid:0,
				ims:this.config.webUrl,
				last_id:0,
				reload: true,
				listData:[],
				status: 'more',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				},
				tabBars: [{
						name: "全部",
						id: "all"
					},{
						name: "待提交",
						id: "提交审核"
					},
					{
						name: "审核中",
						id: "dzf"
					},
					{
						name: "已通过",
						id: "yzf"
					},
					{
						name: "未通过",
						id: "wl"
					},
					{
						name: "复审举报",
						id: "fs"
					},
				],
			}
		},
		//动态倒计时
		created() {
			setTimeout(() => {
				this.testHour = 1
				this.testMinute = 1
				this.testSecond = 0
			}, 2000)
		},
		// 标题栏input搜索框点击
		onNavigationBarSearchInputClicked() {
			uni.navigateTo({
				url: '../search/search'
			});
		},
		onLoad(e) {
			if(e.stype){
				this.tabIndex=e.stype*1
			}
			uni.getSystemInfo({
				success: (res) => {
					let height = res.windowHeight - uni.upx2px(100)
					this.swiperheight = height;
				}
			});
		},
		onShow() {
			this.getList();
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		methods: {
			timeup() {
				uni.showToast({
					title: '时间到'
				})
			},
			getList() {
				let data = {
					//column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
				};
				var limit=10;
				if (this.last_id>0) {
					//说明已有数据，目前处于上拉加载
					this.status = 'loading';
					data.offset = this.last_id*limit;
					data._ = new Date().getTime() + '';
				}
				data.limit=limit
				data.stype=this.tabIndex
				data.token = uni.getStorageSync("userInfo").token;
				data.uid = uni.getStorageSync("userInfo").id;
				var that=this;
				uni.request({
					//url: this.config.webUrl+'/api/order/index',
					url: that.$serverUrl + '/index.php/Mobile/index/getorderindex',
					data: data,
					success: data => {
				let list = data.data.list;
				this.listData = list
					},
					fail: (data, code) => {
					}
				});
			},

			// tabbar点击事件
			tabtap(index) {
				this.tabIndex = index
				this.listData=[];
				this.status = 'more';
				this.last_id=0;
				this.getList();
			},

			ondoctTap(id){
				uni.navigateTo({
					url: `/pages/user/orderrw/orderinfo?id=${id}`
				})
			},
			//得到的秒换算成时分秒
			djs: function(ms) { 
				var h = parseInt(ms / (60 * 60));
				var m = parseInt((ms % (60 * 60)) / 60);
				var s = (ms % (60 * 60)) % 60;
				return h + "小时" + m + "分" + s + "秒";
			},
		}
	}
</script>

<style lang="scss">
	.telis{
		height: 22px;
		// white-space:nowrap;
		// overflow:hidden;
		// text-overflow:ellipsis;
	}
	.text-over{ overflow: hidden; text-overflow: ellipsis;white-space: nowrap;}
	.yybox{
		color: #666;
	}
	.yytp{
		color: #999;
	}
	.searchsc{
		margin-top: 5px;
		color: #999;
		font-size: 28upx;
		padding-left: 90px;
		box-sizing: border-box;
		text-align:justify;
		text-align-last: left;
		overflow:hidden; 
		text-overflow:ellipsis;
		display:-webkit-box; 
		-webkit-box-orient:vertical;
		-webkit-line-clamp:3; 
	}
	.search-con{
		padding:0upx 20upx;
		box-sizing: border-box;
	}
	.search-jcrs{
		color: #999;
	}
	.search-jcrs text{
		font-size: 28upx;
		font-weight: bold;
		color: #d1632d;
	}
	.zxbtn{
		color: #F17503;
		font-size: 32upx;
		height: 46upx;
		font-weight: 500;
		line-height: 46upx;
		border-radius: 28upx;
	}
	.search-nr{
		width: 100%;
		min-height: 88px;
		padding: 20upx;
		margin: 20upx auto;
		border-radius: 16upx;
		-webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
		box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
		margin: 20upx auto;
		background: #fafafa;
		position: relative;
		overflow: hidden;
	}
.avatarbox{
		position: absolute;
		top: 32upx;
		left: 16upx;
		width:130upx;
		height: 130upx;
		border-radius: 16upx;
		overflow: hidden;
	}
	.avatarbox image{
		width: 130upx;
		height: 130upx;
		border-radius: 16upx;
	}
	.search-nrxx>view{
		padding-left: 140upx;
	}
	.xmtitle text:last-child{
		color: #999;
		font-size: 24upx;
	}
	.xmtitle text:first-child{
		color: #666;
		font-size: 30upx;
		padding-right: 10upx;
		font-weight: bold;
		line-height: 20px;
	}
	.satl-img{
		position: absolute;
		top:140upx;
		left:140upx;
		width: 28upx;
		height: 28upx;
		
	}
	
	.swiper-tab-list{
		font-size: 28upx!important;
		font-weight: normal!important;
	}
	.bxmain{
		-webkit-justify-content: space-around;
		justify-content: space-around;
		-webkit-align-content: center;
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
	}
	.bxmain .ts1{
		flex:1;
	}
	.bxmain .ts2{
		flex:3;
	}
	.jbtp{
		font-size: 36upx;
		font-weight: bold;
		color: #3a3a3a;
	}
	.bxbox{
		    display: -webkit-box;
		    display: -webkit-flex;
		    display: flex;
		    -webkit-justify-content: space-around;
		    justify-content: space-around;
		    -webkit-align-content: center;
		    align-content: center;
		    background: #fff;
	}
/* #ifdef MP */
.mp-search-box {
	position: absolute;
	left: 0;
	top: 30upx;
	z-index: 9999;
	width: 100%;
	padding: 0 80upx;
	.ser-input {
		flex: 1;
		height: 56upx;
		line-height: 56upx;
		text-align: center;
		font-size: 28upx;
		color: $font-color-base;
		border-radius: 20px;
		background: rgba(255, 255, 255, 0.6);
	}
}

page {
	.cate-section {
		position: relative;
		z-index: 5;
		border-radius: 16upx 16upx 0 0;
		margin-top: -20upx;
	}
	.carousel-section {
		padding: 0;
		.titleNview-placing {
			padding-top: 0;
			height: 0;
		}
		.carousel {
			.carousel-item {
				padding: 0;
			}
		}
		.swiper-dots {
			left: 45upx;
			bottom: 40upx;
		}
	}
}
/* #endif */

page {
	background: #f9f9f9;
}
.m-t {
	margin-top: 16upx;
}
/* 头部 轮播图 */
.carousel-section {
	position: relative;
	padding-top: 10px;

	.titleNview-placing {
		height: var(--status-bar-height);
		padding-top: 44px;
		box-sizing: content-box;
	}

	.titleNview-background {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 240upx;
		transition: 0.4s;
	}
}
.simtp{
		font-size: 10px;
		color: #fff;
		background: #ffac45;
		padding: 2px 4px;
		border-radius: 3px;
	}
.carousel {
	width: 100%;
	height: 200upx;

	.carousel-item {
		width: 100%;
		height: 100%;
		padding: 0 28upx;
		overflow: hidden;
	}

	image {
		width: 100%;
		height: 100%;
		border-radius: 10upx;
	}
}
.swiper-dots {
	display: flex;
	position: absolute;
	left: 60upx;
	bottom: 15upx;
	width: 72upx;
	height: 36upx;
	background-image: url();
	background-size: 100% 100%;

	.num {
		width: 36upx;
		height: 36upx;
		border-radius: 50px;
		font-size: 24upx;
		color: #fff;
		text-align: center;
		line-height: 36upx;
	}

	.sign {
		position: absolute;
		top: 0;
		left: 50%;
		line-height: 36upx;
		font-size: 12upx;
		color: #fff;
		transform: translateX(-50%);
	}
}
/* 分类 */
.cate-section {
	display: flex;
	justify-content: space-around;
	align-items: center;
	flex-wrap: wrap;
	padding: 30upx 22upx;
	background: #fff;
	.cate-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: $font-sm + 2upx;
		color: $font-color-dark;
	}
	/* 原图标颜色太深,不想改图了,所以加了透明度 */
	image {
		width: 100upx;
		height: 100upx;
		margin-bottom: 14upx;
		border-radius: 50%;
		opacity: 0.9;
		box-shadow: 4upx 4upx 20upx rgba(250, 67, 106, 0.3);
	}
}
.ad-1 {
	width: 100%;
	height: 210upx;
	padding: 10upx 0;
	background: #fff;
	image {
		width: 100%;
		height: 100%;
	}
}
/* 秒杀专区 */
.seckill-section {
	padding:10upx 30upx;
	background: #fff;
	.s-header {
		display: flex;
		align-items: center;
		height: 92upx;
		line-height: 1;
		.s-img {
			width: 140upx;
			height: 30upx;
		}
		.tip {
			font-size: $font-base;
			color: $font-color-light;
			margin: 0 20upx 0 10upx;
			font-size: 24upx;
		}
		.timer {
			display: inline-block;
			width: 40upx;
			height: 36upx;
			text-align: center;
			line-height: 36upx;
			margin-right: 14upx;
			font-size: $font-sm + 2upx;
			color: #fff;
			border-radius: 2px;
			background: rgba(0, 0, 0, 0.8);
		}
		.icon-you {
			font-size: $font-lg;
			color: $font-color-light;
			flex: 1;
			text-align: right;
		}
	}
	.floor-list {
		white-space: nowrap;
	}
	.scoll-wrapper {
		display: flex;
		align-items: flex-start;
		padding: 20upx 0upx;
	}
	.floor-item {
		width: 120px;
		margin-right: 10upx;
		margin-left: 10upx;
		font-size: $font-sm + 2upx;
		color: $font-color-dark;
		text-align: center;
		border-radius: 10upx;
		padding: 20upx 20upx;
		-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
		box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
		image {
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
		}
		.clamp{
			text-align: center;
			font-size: 32upx;
			width: 100px;
			color: #333;
		}
		.price {
			color: #666;
			font-size: 20upx;
			line-height: 2;
			text-align: center;
		}
		.price text{
			font-size: 18upx;
			color: #a1a1a1;
			background: #f8f8f8;
			padding: 4upx 8upx;
			border-radius: 4upx;
		}
		.sums{
			color: #F17503;
			font-size: 32upx;
		}
	}
}

.f-header {
	display: flex;
	align-items: center;
	height: 140upx;
	padding: 6upx 30upx 8upx;
	background: #fff;
	image {
		flex-shrink: 0;
		width: 80upx;
		height: 80upx;
		margin-right: 20upx;
	}
	.tit-box {
		flex: 1;
		display: flex;
		flex-direction: column;
	}
	.tit {
		font-size: $font-lg + 2upx;
		color: #font-color-dark;
		line-height: 1.3;
	}
	.tit2 {
		font-size: $font-sm;
		color: $font-color-light;
	}
	.icon-you {
		font-size: $font-lg + 2upx;
		color: $font-color-light;
	}
}
/* 团购楼层 */
.group-section {
	background: #fff;
	.g-swiper {
		height: 650upx;
		padding-bottom: 30upx;
	}
	.g-swiper-item {
		width: 100%;
		padding: 0 30upx;
		display: flex;
	}
	image {
		width: 100%;
		height: 460upx;
		border-radius: 4px;
	}
	.g-item {
		display: flex;
		flex-direction: column;
		overflow: hidden;
	}
	.left {
		flex: 1.2;
		margin-right: 24upx;
		.t-box {
			padding-top: 20upx;
		}
	}
	.right {
		flex: 0.8;
		flex-direction: column-reverse;
		.t-box {
			padding-bottom: 20upx;
		}
	}
	.t-box {
		height: 160upx;
		font-size: $font-base + 2upx;
		color: $font-color-dark;
		line-height: 1.2;
	}
	.price {
		color: #666;
	}
	.m-price {
		font-size: $font-sm + 2upx;
		text-decoration: line-through;
		color: $font-color-light;
		margin-left: 8upx;
	}
	.pro-box {
		display: flex;
		align-items: center;
		margin-top: 10upx;
		font-size: $font-sm;
		color: $font-base;
		padding-right: 10upx;
	}
	.progress-box {
		flex: 1;
		border-radius: 10px;
		overflow: hidden;
		margin-right: 8upx;
	}
}
/* 猜你喜欢 */
.guess-section {
	display: flex;
	flex-wrap: wrap;
	padding: 0 30upx;
	background: #fff;
	.guess-item {
		display: flex;
		flex-direction: column;
		width: 48%;
		padding-bottom: 40upx;
		&:nth-child(2n + 1) {
			margin-right: 4%;
		}
	}
	.image-wrapper {
		width: 100%;
		height: 330upx;
		border-radius: 3px;
		overflow: hidden;
		image {
			width: 100%;
			height: 100%;
			opacity: 1;
		}
	}
	.title {
		font-size: $font-lg;
		color: $font-color-dark;
		line-height: 80upx;
	}
	.price {
		font-size: $font-lg;
		color: $uni-color-primary;
		line-height: 1;
	}
}
</style>
